package com.example.shape;

import com.example.motion.Touchable;

import org.jbox2d.common.Vec2;

/**
 * Created by Lucas on 17/06/13.
 */
public class Circle implements Touchable {

    /**
     * the x coordinate of the center point of the circle
     */
    private float _xCenter;
    /**
     * the y coordinate of the center point of the circle
     */
    private float _yCenter;
    /**
     * the radius of the circle
     */
    private float _radius;

    /**
     * The constructor of the circle
     * @param xCenter the x coordinate of the center point of the circle
     * @param yCenter the y coordinate of the center point of the circle
     * @param radius the radius of the circle
     */
    public Circle(float xCenter, float yCenter, float radius){
        _xCenter = xCenter;
        _yCenter = yCenter;
        _radius = radius;
    }

    /**
     * return if the circle is touched
     * @param touch the input point to test
     * @return
     */
    public boolean isTouched(Vec2 touch){
        return isTouched(touch.x, touch.y);
    }

    /**
     * return if the circle is touched
     * @param xCenter
     * @param yCenter
     * @return
     */
    public boolean isTouched(float xCenter, float yCenter){
        float distance=0f;
        distance  = ((xCenter-_xCenter)*(xCenter-_xCenter));
        distance += ((yCenter-_yCenter)*(yCenter-_yCenter));

        distance = (float) Math.sqrt(distance);
        if (distance <= _radius){
            return true;
        }
        return false;
    }

}
